package org.come.baitan;

import com.tool.tcpimg.UIUtils;
import org.come.until.FormsManagement;
import org.come.until.MessagrFlagUntil;
import org.come.until.Music;
import org.come.until.ScrenceUntil;

import javax.swing.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

/**
 * @author 式
 * @version 1.0
 * @project test1
 * @description 购买主窗口
 * @date 2024/1/30 20:48:24
 */
public class GouMaizhuFrame extends JInternalFrame implements MouseListener {
	private GouMaiJpanel gouMaiJpanel=new GouMaiJpanel();
private int first_x;
private int first_y;
public static GouMaizhuFrame getGouMaizhuFrame(){
	return  (GouMaizhuFrame) FormsManagement.getInternalForm(2261).getFrame();
}
public GouMaizhuFrame(){
	this.getContentPane().add(gouMaiJpanel);
	this.setBorder(BorderFactory.createEmptyBorder());
	((BasicInternalFrameUI)this.getUI()).setNorthPane(null);
	this.setBackground(UIUtils.Color_BACK);
	this.setBounds(ScrenceUntil.Screen_x/2-300, ScrenceUntil.Screen_y/2-300, 402, 450);
	this.pack();
	this.setVisible(false);
	this.setDefaultCloseOperation(3);
	this.addMouseListener((MouseListener)this);
	this.addMouseMotionListener(new MouseMotionListener() {
		@Override
		public void mouseDragged(MouseEvent e) {
			if (isVisible()) {
				final int x = e.getX() - first_x;
				final int y = e.getY() - first_y;
				setBounds(x + getX(), y + getY(), getWidth(),getHeight());
			}
		}
		
		@Override
		public void mouseMoved(MouseEvent e) {
			if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE13)) {
				MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
			}
		}
	});
}
@Override
public void mouseClicked(MouseEvent e) {

}

@Override
public void mousePressed(MouseEvent e) {
	FormsManagement.showForm(2261);
	Music.addyinxiao("关闭窗口.mp3");
	if (e.isMetaDown()) {
		FormsManagement.HideForm(2261);
	}
	else {
		FormsManagement.Switchinglevel(2261);
	}
	this.first_x = e.getX();
	this.first_y = e.getY();
}

@Override
public void mouseReleased(MouseEvent e) {

}

@Override
public void mouseEntered(MouseEvent e) {

}

@Override
public void mouseExited(MouseEvent e) {

}

public GouMaiJpanel getGouMaiJpanel() {
	return gouMaiJpanel;
}

public void setGouMaiJpanel(GouMaiJpanel gouMaiJpanel) {
	this.gouMaiJpanel = gouMaiJpanel;
}

public int getFirst_x() {
	return first_x;
}

public void setFirst_x(int first_x) {
	this.first_x = first_x;
}

public int getFirst_y() {
	return first_y;
}

public void setFirst_y(int first_y) {
	this.first_y = first_y;
}
}
